import java.io.*;

public class IODemo3 {
    public static void main(String[] args) throws FileNotFoundException {
        // 使用字符流读取文件内容
    try ( Reader reader = new FileReader("./test.txt")){
        //读文件
        while(true){
            char[]buffer = new char[1024];
            int n = reader.read(buffer);
            if(n==-1){
                //判断成功表示读取完毕
                break;
            }
            //打印方式一
            //String s = new String(buffer,0,n);
           // System.out.println(s);
            //打印方式二
            for (int i = 0; i < n; i++) {
                System.out.print(buffer[i]);
                System.out.print(" ");

            }
        }
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    }
}
